<template>
  <div id="WgtDataDetails">
    <v-detail
      :detailData="inputData.detailData"
      :inputConfig="inputConfig"
      :rules="rules"
      ref="input"
    ></v-detail>
  </div>
</template>

<script>
import detail from "commons/Detail";
import baseMixin from "@/mixins/BaseMixin";

export default {
  name: "WgtDataDetails",
  mixins: [baseMixin],
  props: {
    inputData: {
      type: Object
    }
  },
  data () {
    return {
      rules: {
        ocwby: [
          { validator: this.ocwby, trigger: 'blur' },
        ],
      },
      whseidflag: false
    }
  },
  computed: {
    inputConfig () {
      return [
        [
          {
            type: "checkbox",
            label: this.$t('outbound.icwflag'),
            props: "icwflag",
            disabled: this.whseidflag
          },
          {
            type: "checkbox",
            label: this.$t('outbound.ideweight'),
            props: "ideweight",
            disabled: this.whseidflag
          },
          {
            type: "input",
            label: this.$t('outbound.avgcaseweight'),
            props: "avgcaseweight",
            disabled: true
          },
          {
            type: "input",
            label: this.$t('config.tareWeight'),
            props: "tareweight",
            disabled: true
          },
          {
            type: "input",
            label: this.$t('outbound.tolerancepct'),
            props: "tolerancepct",
            disabled: true
          },
          {
            type: "select",
            label: this.$t('outbound.icwby'),
            props: "icwby",
            disabled: this.whseidflag,
            options: this.getOptions('queryCwbyDropDown')
          },
          {
            type: "select",
            label: this.$t('outbound.fillqtyuom'),
            props: "fillqtyuom",
            disabled: this.whseidflag,
            options: this.getOptions('querycodeLkup/FILLQTYUOM')
          },
        ],
        [
          {
            type: "checkbox",
            label: this.$t('outbound.snumEndtoend'),
            props: "snum_Endtoend",
            disabled: this.whseidflag
          },
          {
            type: "checkbox",
            label: this.$t('outbound.icdflag'),
            props: "icdflag",
            disabled: this.whseidflag
          },
          {
            type: "checkbox",
            label: this.$t('outbound.icd1unique'),
            props: "icd1unique",
            disabled: this.whseidflag
          },
          {
            type: "input",
            label: this.$t('outbound.other',{no:1}),
            props: "icdlabel1",
            disabled: true
          },
          {
            type: "input",
            label: this.$t('outbound.other',{no:2}),
            props: "icdlabel2",
            disabled: true
          },
          {
            type: "input",
            label: this.$t('outbound.other',{no:3}),
            props: "icdlabel3",
            disabled: true
          },
          {
            type: "input",
            label: this.$t('outbound.other',{no:4}),
            props: "icdlabel4",
          },
          {
            type: "input",
            label: this.$t('outbound.other',{no:5}),
            props: "icdlabel5",
            disabled: true
          },
        ],
        [
          {
            type: "checkbox",
            label: this.$t('outbound.ocwflag'),
            props: "ocwflag",
            disabled: this.whseidflag
          },
          {
            type: "checkbox",
            label: this.$t('outbound.ideweight'),
            props: "odeweight",
            disabled: this.whseidflag
          },
          {
            type: "input",
            label: this.$t('outbound.avgcaseweight'),
            props: "oavgcaseweight",
            disabled: true
          },
          {
            type: "input",
            label: this.$t('outbound.tolerancepct'),
            props: "otolerancepct",
            disabled: true
          },
          {
            type: "input",
            label: this.$t('outbound.icwby'),
            props: "ocwby",
            disabled: this.whseidflag
          },
        ],
        [
          {
            type: "checkbox",
            label: this.$t('outbound.ocdflag'),
            props: "ocdflag",
            disabled: this.whseidflag
          },
          {
            type: "checkbox",
            label: this.$t('outbound.oacoverride'),
            props: "oacoverride",
            disabled: this.whseidflag
          },
          {
            type: "checkbox",
            label: this.$t('outbound.ocd1unique'),
            props: "ocd1unique",
            disabled: this.whseidflag
          },
        ],
          [
              {
                  type: "input",
                  label: this.$t('outbound.other',{no:1}),
                  props: "ocdlabel1",
                  disabled: true
              },
              {
                  type: "select",
                  label: this.$t('outbound.ocdcatchwhen'),
                  props: "ocdcatchwhen",
                  disabled: this.whseidflag,
                  options: this.getOptions('querycodeLkup/CATCHWHEN')
              },
              {
                  type: "input",
                  label: this.$t('outbound.other',{no:2}),
                  props: "ocdlabel2",
                  disabled: true
              },
              {
                  type: "select",
                  label: this.$t('outbound.ocdcatchqty',{no:1}),
                  props: "ocdcatchqty1",
                  disabled: this.whseidflag,
                  options: this.getOptions('querycodeLkup/CATCHQTY')
              },
              {
                  type: "input",
                  label: this.$t('outbound.other',{no:3}),
                  props: "ocdlabel3",
                  disabled: true
              },
              {
                  type: "select",
                  label: this.$t('outbound.ocdcatchqty',{no:2}),
                  props: "ocdcatchqty2",
                  disabled: this.whseidflag,
                  options: this.getOptions('querycodeLkup/CATCHQTY')
              },
              {
                  type: "input",
                  label: this.$t('outbound.other',{no:4}),
                  props: "ocdlabel4",
                  disabled: true
              },
              {
                  type: "select",
                  label: this.$t('outbound.ocdcatchqty',{no:3}),
                  props: "ocdcatchqty3",
                  disabled: this.whseidflag,
                  options: this.getOptions('querycodeLkup/CATCHQTY')
              },
              {
                  type: "input",
                  label: this.$t('outbound.other',{no:5}),
                  props: "ocdlabel5",
                  disabled: true
              },
              {
                  type: "select",
                  label: this.$t('outbound.voicegroupingid'),
                  props: "voicegroupingid",
                  options: this.getOptions('querycodeLkup/VOICEGRID'),
                  disabled: this.whseidflag,
              },
          ]
      ]
    }
  },
  methods: {
    ocwby (rule, value, callback) {
      if (value === '') {
        callback(new Error());
      } else {
        var re = /[^0-9.]/;
        let te = value;
        let flag = re.test(te)
        if (!flag) {
          if (value < 0) {
            this.$message.error(this.$t('app.inputNumberPlease'))
            this.inputData.detailData[rule.field] = 0
            callback(new Error());
          } else {
            callback();
          }
        } else {
          this.$message.error(this.$t('app.inputNumberPlease'))
          this.inputData.detailData[rule.field] = 0
          callback(new Error());
        }
      }
    },
  },
  mounted () {
    if (this.$store.state.wms.toUpperCase().includes('WMWHSE')) {
      //仓库级
      this.whseidflag = true;
    }
  },
  components: {
    "v-detail": detail
  }
}
</script>

<style scoped>
</style>
